package com.asset.dispoal.dataDetail;

import com.asset.dispoal.dataDetail.api.SysDataTypeService;
import com.asset.dispoal.dataDetail.dto.SysDataDetailGeneratorRequest;
import com.asset.dispoal.dataDetail.dto.SysDataDetailTemplateResponse;
import com.asset.dispoal.dataDetail.dto.SysDataType;
import com.asset.dispoal.dataDetail.dto.SysDataTypeDetailTemplate;
import com.asset.dispoal.dataDetail.dto.SysDataTypePage;
import com.asset.dispoal.dataDetail.dto.SysDataTypeSaveRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

import java.util.List;

@RestController
@Api(value = "数据清单类型", tags = "数据清单类型")
@RequestMapping("system/dataType")
public class SysDataTypeController {

    @Autowired
    private SysDataTypeService sysDataTypeService;

    @GetMapping("queryPage")
    @ApiOperation(value = "查询", notes = "查询")
    public Result<PageVO<SysDataTypePage>> queryPage(SysDataTypePage sysDataTypePage) {
        return sysDataTypeService.queryPage(sysDataTypePage);
    }

    @PostMapping("save")
    @ApiModelProperty(value = "保存", notes = "保存")
    public Result save(@RequestBody SysDataTypeSaveRequest saveRequest) {
        return sysDataTypeService.save(saveRequest);
    }

    @DeleteMapping("delete")
    @ApiModelProperty(value = "删除", notes = "删除")
    public Result delete(String id) {
        return sysDataTypeService.delete(id);
    }

    @GetMapping("queryTemplateList")
    @ApiModelProperty(value = "查询模板列表", notes = "查询模板列表")
    public Result<List<SysDataDetailTemplateResponse>> queryTemplateList() {
        return Result.ok(sysDataTypeService.queryTemplateList());
    }

    @GetMapping("/queryTemplateListById")
    @ApiModelProperty(value = "根据id查询模板列表", notes = "根据id查询模板列表")
    public Result<List<SysDataTypeDetailTemplate>> queryTemplateListById(String id) {
        return Result.ok(sysDataTypeService.queryTemplateListById(id));
    }

    @GetMapping("queryTypeList")
    @ApiModelProperty(value = "查询数据清单类型", notes = "查询数据清单类型")
    public Result<List<SysDataType>> queryTypeList() {
        return Result.ok(sysDataTypeService.queryTypeList());
    }

    @GetMapping("/queryDataDetailByAssetInstBatchId")
    @ApiOperation(value = "根据批次查询数据清单类型", notes = "根据批次查询数据清单类型")
    public Result<List<SysDataTypeDetailTemplate>> queryDataDetailByAssetInstBatchId(String assetInstBatchId) {
        return Result.ok(sysDataTypeService.queryDataDetailByAssetInstBatchId(assetInstBatchId));
    }

    @PostMapping("generator")
    @ApiOperation(value = "初始化", notes = "初始化")
    public Result generator(@RequestBody SysDataDetailGeneratorRequest request) {
        sysDataTypeService.generator(request);
        return Result.ok();
    }
}
